﻿Imports MySql.Data.MySqlClient
Public Class dConsultar
    Private con As MySqlConnection
    Private comando As MySqlCommand
    Dim lector As MySqlDataReader
    Private lector2 As MySqlDataAdapter
    Private data As DataSet
    Public Function Consultar_General(ByVal campo As String, ByVal Tabla As String) As DataSet
        con = Conexion.open()
        Select Case Tabla
            Case "Analistas"
                comando = New MySqlCommand("Select codigo_analista as Codigo, nombre_analista as analista, Telefono, Direccion, Email from analistas where codigo_analista='" & campo & "' or nombre_analista like '" & "%" & campo & "%" & "' and estado_analista='A'", con)
            Case "Empresas"
                comando = New MySqlCommand("Select codigo_empresa as Codigo, razon_social as Empresa, Direccion, Telefono, Email, Pagina_Web from empresas where codigo_empresa='" & campo & "' or razon_social like '" & "%" & campo & "%" & "' and estado_empresa='A'", con)
            Case "Usuarios"
                comando = New MySqlCommand("Select codigo_usuario as Codigo, concat(primer_nombre,' ',segundo_nombre,' ',primer_apellido,' ',segundo_apellido) as Nombre from usuarios where codigo_usuario='" & campo & "' or concat(primer_nombre,' ',segundo_nombre,' ',primer_apellido,' ',segundo_apellido) like '" & "%" & campo & "%" & "'", con)
        End Select
        lector2 = New MySqlDataAdapter(comando)
        data = New DataSet
        lector2.Fill(data)
        Conexion.Close(con)
        Return data
    End Function
End Class
